const userpl=require("../models/userpl")


//获取所有博客信息
exports.getboke=async function (){
    const result=await userpl.findAll()
    return result;
}

// 分页查询
const {
    Op, where
} = require("sequelize");

exports.getfenye= async function (page = 1, limit = 10) {
      const result = await userpl.findAndCountAll({
        offset: (page - 1) * limit,
        limit: +limit,
    })
    return JSON.parse(JSON.stringify(result))
}
//查
exports.getmoodidfind = async function (page = 1, limit = 10,MoodId) {
    const result = await userpl.findAndCountAll({
        offset: (page - 1) * limit,
        limit: +limit,
        where:{
           MoodId:MoodId
        }
    })
    return JSON.parse(JSON.stringify(result))
}
//添加修改
exports.updateBoke = async function (id, obj) {
    return await userpl.update(obj, {
        where: {
            id
        }
    });
}

exports.adduserpl=async function(obj){
    
    const result=await userpl.create(obj)

    return result.toJSON()
}